<?
include_once("codelibrary/inc/variables.php");
include_once("session.php");
include_once("codelibrary/inc/functions.php");
$business_id = $_SESSION['business_id'];

function query($query,$extra="")
{
	$result = mysql_query($query) or die("Query execution error : ".mysql_error()."<br> Query : $query <br> Query Type : $extra");
	return $result;
}

$app_setting = array();
$query = "select * from appointment_setting where business_id='".$business_id."' group by setting_name";
$res = query($query);
	
while($row = mysql_fetch_object($res)) {
		$app_setting[$row->setting_name] = $row->setting_value;
	}



foreach ($_POST as $key => $value) {
	
	if($value!=$app_setting[$key])
	{
		$query = "update appointment_setting set setting_value = '".$value."' where business_id=$business_id and setting_name='".$key."'";
		$res = query($query);
		if(mysql_affected_rows()==0) {
			$query = "insert into appointment_setting(setting_name,setting_value,business_id) values('".$key."','".$value."','".$business_id."')";
			$res = query($query);
		}
	}
}

if($_POST)
{
	$app_setting = $_POST;
}

unset($app_setting['Submit']);
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html dir="LTR" lang="en">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<title>Online Appointment</title>

<base >
<link rel="stylesheet" type="text/css" href="stylesheet.css">
<title>Staff Management</title>

</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">


<table cellpadding="0" cellspacing="0" border="0"><tr>
  <td style="background:url(images/top.gif) repeat-x top; ">
<table cellpadding="0" cellspacing="0" border="0" style="width:764px" align="center"> 
	<tr>
		<td>
			<table cellpadding="0" cellspacing="0" border="0" style="height:57">
				<tr>
					<td height="57">
<? html_header(); ?>					</td>
				</tr>
			</table>


		</td>
	</tr>
	<tr>
		<td>





<table border="0" width="105%" cellspacing="0" cellpadding="0">
  <tr>
    <td valign="top" class="col_left">

<table border="0"cellspacing="0" cellpadding="0" class="box_width_left">
	<tr><td width="100%">
		<table border="0" cellspacing="0" cellpadding="0">
<tr><td>

<table border="0" width="100%" cellspacing="0" cellpadding="0" class="">
  <tr>
    <td>
    <table border="0" width="100%" cellspacing="0" cellpadding="0"  class="" height="91">
  <tr>
    <td align="center" height="91">
    <img border="0" src="images/logo.jpg" width="208" height="86"></td>
  </tr>
</table>
</td>
  </tr>
</table>
</td></tr>


          <tr>
            <td>
<table border="0" width="100%" cellspacing="0" cellpadding="0"  class="box_header_txt" height="48">
  <tr>
    <td style="background-image: url(images/1_bg2-2.gif)" height="1">
      <p style="margin-top: 16"> </td>
  </tr>
</table>
<table border="0" width="100%" cellspacing="0" cellpadding="0"   style="border-bottom:12px solid #ffffff;">
  <tr>
    <td>
    <table border="0" width="100%" cellspacing="0" cellpadding="0"  style="margin-bottom:0px;background:#7C7C7C url(images/1_line.gif) no-repeat left bottom;" >
  <tr>
    <td  style="padding:3px 16px 8px 25px;">
      <? include("link.php");?>
    </td>
  </tr>
</table>
</td>
  </tr>
</table>
            </td>
          </tr>


          <tr>
            <td class="">&nbsp;
</td>
          </tr>

		</table>
	</td>
	<td><img src="images/spacer.gif" border="0" alt="" width="15" height="1"></td></tr>
</table>

    </td>

    <td width="100%" valign="top">
<table border="0" width="100%" cellspacing="0" cellpadding="0"  class="cont_header_txt">
  <tr>
    <td>
			<table border="0" cellpadding="0" cellspacing="0" bgcolor="#EAEAEA" class="cont_header_txt">
				<tr>
					<td><img src="images/1_q1.gif" border="0" alt="" width="45" height="39"></td>
					<td style="width:100%">appointment setting </td>
					<td><img src="images/1_q2.gif" border="0" alt="" width="10" height="39"></td>
				</tr>
			</table>										 
			</td>
  </tr>
</table>


						

					 <form name="ap_form" method="post" action="appointment_setting.php">  
					 	<table cellpadding="0" cellspacing="0" border="0" style="border:0px solid #DEDEDE; border-width:0px 1px 0px 1px;">
                          <tr>
                            <td style="background:#ffffff;border:0px solid #ffffff; border-width:18px 5px 10px 5px;"><!-- new_products //-->
                                <table border="0" width="" cellspacing="0" cellpadding="0">
                                  <tr>
                                    <td>
									<table width="200" border="1" cellspacing="5" bordercolor="#FFDBCA" class="table">
                                  
									  <tr>
                                        <td width="74%" valign="middle" class="simpletxt"><div align="justify"><strong>1.</strong> Appointments start</div></td>
                                        <td width="26" colspan="2">
                                          <label>
                                            <select name="appointment_start" id="appointment_start">
                                              <option value="">Select start time</option>
                                              <option value="1">Every 1 minutes</option>
                                              <option value="2">Every 2 minutes</option>
                                              <option value="3">Every 3 minutes</option>
                                              <option value="4">Every 4 minutes</option>
                                              <option value="5">Every 5 minutes</option>
                                              <option value="6">Every 6 minutes</option>
                                              <option value="7">Every 7 minutes</option>
                                              <option value="8">Every 8 minutes</option>
                                              <option value="9">Every 9 minutes</option>
                                              <option value="10">Every 10 minutes</option>
                                              <option value="15">Every 15 minutes</option>
                                              <option value="20">Every 20 minutes</option>
                                              <option value="25">Every 25 minutes</option>
                                              <option value="30">Every 30 minutes</option>
                                              <option value="35">Every 35 minutes</option>
                                              <option value="40">Every 40 minutes</option>
                                              <option value="45">Every 45 minutes</option>
                                              <option value="50">Every 50 minutes</option>
                                              <option value="60">Every 60 minutes</option>
                                              <option value="75">Every 75 minutes</option>
                                              <option value="90">Every 90 minutes</option>
                                              <option value="105">Every 105 minutes</option>
                                              <option value="120">Every 120 minutes</option>
                                              <option value="150">Every 150 minutes </option>
                                              <option value="180">Every 180 minutes</option>
                                              </select>
                                          </label>
                                       </td>
                                      </tr>
                                      <tr>
                                        <td valign="middle" class="simpletxt"><div align="justify"><strong>2.</strong> How far in advance can customers make appointments for services?</div></td>
                                        <td colspan="2">
                                          <label>
                                            <select name="advance_appointment" id="advance_appointment">
                                              <option value="">---Select---</option>
                                              <option value="1">1 day</option>
                                              <option value="2">2 days</option>
                                              <option value="3">3 days</option>
                                              <option value="4">4 days</option>
                                              <option value="5">5 days</option>
                                              <option value="6">6 days</option>
                                              <option value="7">7 days </option>
                                              <option value="8">8 days</option>
                                              <option value="9">9 days</option>
                                              <option value="10">10 days</option>
                                              <option value="14">14 days</option>
                                              <option value="21">21 days</option>
                                              <option value="30">30 days</option>
                                              <option value="60">60 days</option>
                                              <option value="90">90 days</option>
                                              <option value="180">180 days</option>
                                              <option value="360">360 days</option>
                                              <option value="720">720 days</option>
                                              </select>
                                          </label>
                                       </td>
                                      </tr>
                                      <tr>
                                        <td valign="middle" class="simpletxt"><div align="justify"><strong>3.</strong> How far in advance can customers make appointments for events?</div></td>
                                        <td colspan="2"><select name="advancebook_event" id="advancebook_event">
                                          <option value="">---Select---</option>
                                          <option value="1">1 day</option>
                                          <option value="2">2 days</option>
                                          <option value="3">3 days</option>
                                          <option value="4">4 days</option>
                                          <option value="5">5 days</option>
                                          <option value="6">6 days</option>
                                          <option value="7">7 days </option>
                                          <option value="8">8 days</option>
                                          <option value="9">9 days</option>
                                          <option value="10">10 days</option>
                                          <option value="14">14 days</option>
                                          <option value="21">21 days</option>
                                          <option value="30">30 days</option>
                                          <option value="60">60 days</option>
                                          <option value="90">90 days</option>
                                          <option value="180">180 days</option>
                                          <option value="360">360 days</option>
                                          <option value="720">720 days</option>
                                        </select></td>
                                      </tr>
                                      <tr>
                                        <td valign="middle" class="simpletxt"><div align="justify"><strong>4.</strong> How many days after the current day can customers make appointments?</div></td>
                                        <td colspan="2">
                                          <label>
                                            <select name="aftercurrentday" id="aftercurrentday">
                                              <option selected="selected" value="">---Select----</option>
                                              <option value="0">Allow same day appointment</option>
                                              <option value="1">1 day</option>
                                              <option value="2">2 days</option>
                                              <option value="3">3 days</option>
                                              <option value="4">4 days</option>
                                              <option value="5">5 days</option>
                                              <option value="6">6 days</option>
                                              <option value="7">7 days</option>
                                              <option value="14">14 days</option>
                                          </select>
                                          </label>
                                         </td>
                                      </tr>
                                      <tr>
                                        <td valign="middle" class="simpletxt"><div align="justify"><strong>5.</strong> Allow recurring appointments</div></td>
                                        <td>
                                          <label>
                                            <input name="recurring" type="radio" value="1">
                                          </label>
                                          <span class="simpletxt">Yes</span>
                                          </td>
                                        <td><input name="recurring" type="radio" value="0" checked>
                                          <span class="simpletxt">No</span></td>
                                      </tr>
                                      <tr>
                                        <td valign="middle" class="simpletxt"><div align="justify"><strong>6.</strong> Show customer information fields (address, phone number, etc.) when making or   viewing an appointment.</div></td>
                                        <td><label>
                                          <input name="cust_information" type="radio" value="1" checked>
                                        </label>
                                          <span class="simpletxt">Yes</span></td>
                                        <td><input name="cust_information" type="radio" value="0">
                                          <span class="simpletxt">No</span></td>
                                      </tr>
                                      <tr>
                                        <td valign="middle" class="simpletxt"><div align="justify"><strong>7.</strong> When making or updating appointments in admin, display the cost field.</div></td>
                                        <td><label>
                                          <input name="display_cost" type="radio" value="1" checked>
                                        </label>
                                          <span class="simpletxt">Yes</span></td>
                                        <td><input name="display_cost" type="radio" value="0">
                                          <span class="simpletxt">No</span></td>
                                      </tr>
                                      <tr>
                                        <td valign="middle" class="simpletxt"><div align="justify"><strong>8.</strong> Show appointment statistics for customers when making or viewing   appointments.</div></td>
                                        <td><label>
                                          <input name="appointment_statistics" type="radio" value="1">
                                        </label>
                                          <span class="simpletxt">Yes</span></td>
                                        <td><input name="appointment_statistics" type="radio" value="0">
                                          <span class="simpletxt">No</span></td>
                                      </tr>

                                      <tr>
                                        <td valign="middle" class="simpletxt"><div align="justify"><strong>9.</strong> On the appointment grid, hide the schedule for the day if the staff member   is off on that day.</div></td>
                                        <td><label>
                                          <input name="hide_schedule" type="radio" value="1">
                                        </label>
                                          <span class="simpletxt">Yes</span></td>
                                        <td><label>
                                          <input name="hide_schedule" type="radio" value="0">
                                        </label>
                                          <span class="simpletxt">No</span></td>
                                      </tr>
                                      <tr>
                                        <td valign="middle" class="simpletxt"><div align="justify"><strong>10.</strong> On the appointment grid, don't allow appointments to be made on unavailable   days/times.</div></td>
                                        <td><label>
                                          <input name="unavailable_time" type="radio" value="1">
                                        </label>
                                          <span class="simpletxt">Yes</span></td>
                                        <td><label>
                                          <input name="unavailable_time" type="radio" value="0">
                                        </label>
                                          <span class="simpletxt">No</span></td>
                                      </tr>
                                      <tr>
                                        <td valign="middle" class="simpletxt"><div align="justify"><strong>11.</strong> If using the multiple appointments per time slot version, allow admin users   to add more than the maximum number of appointments in a time slot.</div></td>
                                        <td><label>
                                          <input name="maxnum_appointment" type="radio" value="1">
                                        </label>
                                          <span class="simpletxt">Yes</span></td>
                                        <td><label>
                                          <input name="maxnum_appointment" type="radio" value="0">
                                        </label>
                                          <span class="simpletxt">No</span></td>
                                      </tr>
                                      <tr>
                                        <td valign="middle" class="simpletxt"><div align="justify"><strong>12.</strong> Turn off the ability to reserve time slots on the appointment grid. This   will result in the Q and R boxes being hidden on the grid. It will also disallow   the cancelling of reserved time if the reserved time was made via the staff   members section.</div></td>
                                        <td><label>
                                          <input name="reserve_timeslot" type="radio" value="1">
                                        </label>
                                          <span class="simpletxt">Yes</span></td>
                                        <td><label>
                                          <input name="reserve_timeslot" type="radio" value="0" checked>
                                        </label>
                                          <span class="simpletxt">No</span></td>
                                      </tr>
                                      <tr>
                                        <td valign="middle" class="simpletxt"><div align="justify"><strong>13.</strong> Turn off the ability to reserve time slots on the appointment grid for the   call center user type.</div></td>
                                        <td><label>
                                          <input name="city" type="radio" value="1">
                                        </label>
                                          <span class="simpletxt">Yes</span></td>
                                        <td><label>
                                          <input name="city" type="radio" value="0">
                                        </label>
                                          <span class="simpletxt">No</span></td>
                                      </tr>
                                      <tr>
                                        <td valign="middle" class="simpletxt"><div align="justify"><strong>14.</strong> If using the one appointment per time slot version, allow additional   appointments to be made in the same time slot (only applies to site   administration) and allow overlapping appointments.</div></td>
                                        <td><label>
                                          <input name="appointment_slot" type="radio" value="1">
                                        </label>
                                          <span class="simpletxt">Yes</span></td>
                                        <td><label>
                                          <input name="appointment_slot" type="radio" value="0">
                                        </label>
                                          <span class="simpletxt">No</span></td>
                                      </tr>
                                      <tr>
                                        <td valign="middle" class="simpletxt"><div align="justify"><strong>15.</strong> Show the "I" (information) icon on the appointment grid.</div></td>
                                        <td><label>
                                          <input name="information" type="radio" value="1" checked>
                                        </label>
                                          <span class="simpletxt">Yes</span></td>
                                        <td><label>
                                          <input name="information" type="radio" value="0">
                                        </label>
                                          <span class="simpletxt">No</span></td>
                                      </tr>
                                      <tr>
                                        <td valign="middle" class="simpletxt"><div align="justify"><strong>16.</strong> Display cancellation policy popup on the front end when a customer cancels.</div></td>
                                        <td><label>
                                          <input name="cancellation_policy" type="radio" value="1">
                                        </label>
                                          <span class="simpletxt">Yes</span></td>
                                        <td><label>
                                          <input name="cancellation_policy" type="radio" value="0">
                                        </label>
                                          <span class="simpletxt">No</span></td>
                                      </tr>
                                      <tr>
                                        <td valign="middle" class="simpletxt"><div align="justify"><strong>17.</strong> Display cancellation policy popup in admin upon cancelling.</div></td>
                                        <td><label>
                                          <input name="cancellation_admin" type="radio" value="1">
                                        </label>
                                          <span class="simpletxt">Yes</span></td>
                                        <td><label>
                                          <input name="cancellation_admin" type="radio" value="0">
                                        </label>
                                          <span class="simpletxt">No</span></td>
                                      </tr>
                                      <tr>
                                        <td valign="middle" class="simpletxt"><div align="justify"><strong>18.</strong> Display cancellation policy popup in admin when finalizing appointments.</div></td>
                                        <td><label>
                                          <input name="cancellation_finalizing" type="radio" value="1">
                                        </label>
                                          <span class="simpletxt">Yes</span></td>
                                        <td><label>
                                          <input name="cancellation_finalizing" type="radio" value="0">
                                        </label>
                                          <span class="simpletxt">No</span></td>
                                      </tr>
                                      <tr>
                                        <td valign="middle" nowrap class="simpletxt"><div align="justify"><strong>19.</strong> Require a reason for cancellation on the front end.</div></td>
                                        <td><label>
                                          <input name="cancellation_reason_front" type="radio" value="1">
                                        </label>
                                          <span class="simpletxt">Yes</span></td>
                                        <td><label>
                                          <input name="cancellation_reason_front" type="radio" value="0">
                                        </label>
                                          <span class="simpletxt">No</span></td>
                                      </tr>
                                      <tr>
                                        <td valign="middle" class="simpletxt"><div align="justify"><strong>20.</strong> Require a reason for cancellation in admin.</div></td>
                                        <td><label>
                                          <input name="cancellation_reason_admin" type="radio" value="1">
                                        </label>
                                          <span class="simpletxt">Yes</span></td>
                                        <td><label>
                                          <input name="cancellation_reason_admin" type="radio" value="0">
                                        </label>
                                          <span class="simpletxt">No</span></td>
                                      </tr>
                                      <tr>
                                        <td valign="middle" nowrap class="simpletxt"><div align="justify"><strong>21.</strong> Cancellation policy to display on the front end.</div></td>
                                        <td colspan="2">
                                          <label>
                                            <textarea name="display_policy_front" rows="5" id="display_policy_front"></textarea>
                                          </label>
                                        </td>
                                      </tr>
                                      <tr>
                                        <td valign="middle" class="simpletxt"><div align="justify"><strong>22.</strong> Cancellation policy to display in admin.</div></td>
                                        <td colspan="2">
                                          <label>
                                            <textarea name="display_policy_admin" rows="5" id="display_policy_admin"></textarea>
                                          </label>
                                                   </td>
                                      </tr>
                                      <tr>
                                        <td valign="middle" class="simpletxt"><div align="justify"><strong>23.</strong> Allow appointments made in site administration to end after the location's   closing time.</div></td>
                                        <td><label>
                                          <input name="location_closing" type="radio" value="1">
                                        </label>
                                          <span class="simpletxt">Yes</span></td>
                                        <td><label>
                                          <input name="location_closing" type="radio" value="0">
                                        </label>
                                          <span class="simpletxt">No</span></td>
                                      </tr>
                                      <tr>
                                        <td>&nbsp;</td>
                                        <td colspan="2">&nbsp;</td>
                                      </tr>
                                      <tr>
                                        <td colspan="3" align="center">
                                          <label>
                                            <input name="Submit" type="submit" class="button" value="Update">
                                          </label>
                                        
                                        </td>
                                      </tr>
                                    </table>
									</td>
                                  </tr>
                         
							    </table>
								
                              <table border="0" cellspacing="0" cellpadding="0" align="center">
                                  <tr>
                                    <td></td>
                                  </tr>
                              </table></td>
                          </tr>
                        </table>
						      </form>
			
						
						<table cellpadding="0" cellspacing="0" border="0">
							<tr>
								<td><img src="images/1_q4.gif" border="0" alt="" width="10" height="10"></td>
								<td style="width:100%; background-image:url(images/1_li1.gif)"></td>
								<td><img src="images/1_q3.gif" border="0" alt="" width="10" height="10"></td>
							</tr>
						</table>
						


		
		
		</td>

    <td class="col_right">

<table border="0"cellspacing="0" cellpadding="0" class="box_width_right">
	<tr><td></td>
		<td width="100%">
			<table border="0" cellspacing="0" cellpadding="0">
				<tr><td></td></tr>
			</table>
		</td>
	</tr>
</table>


    </td>
  </tr>
</table>



		</td>
	</tr>
	<tr>
		<td>
			<table cellpadding="0" cellspacing="0" border="0" style="height:98px; background-image:url(images/bot.gif)">
				<tr>
					<td>
						<table cellpadding="0" cellspacing="0" border="0" class="footer">
							<tr>									
								<td height="77"><img src="images/spacer.gif" border="0" alt="" width="25" height="1"></td>				
								<td style="width:207px"><br style="line-height:49px"><img src="images/p1.gif" border="0" alt="" width="145" height="24"><br></td>
							  <td style="width:532px">&nbsp;</td>
							</tr>
						</table>
					</td>
				</tr>
			</table>
		</td>
	</tr>
</table></td></tr></table>
						  <script>
							  function setvalue(obj,val)
							  {


								  if(obj.type=="select-one" || obj.type=="textarea")
									  obj.value = val;
								  else {
									 for (i = 0; i <obj.length; i++) {
										if( obj[i].value == val)
											break;
									 }
									 obj[i].checked = "true";
								  }

							  }
							  <?
							  	foreach ($app_setting as $key => $value) {
									//print 'document.ap_form.'.$key.'.value="'.$value.'";'."\n";
									print 'setvalue(document.ap_form.'.$key.',"'.$value.'");'."\n";
								}
							  ?>
							 

							  </script>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
  <tr>
    <td align="center"></td>
  </tr>
</table>
</body>

</html>			